package com.zpark.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @PackageName: com.zpark.config
 * @ClassName: Swagger2Config
 * @Description:
 * @author: RZS
 * @date: 2022/10/18  10:36
 */
@Configuration
// 开启swagger2注解功能
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.zpark.controller"))
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                // 设置标题
                .title("这是文档描述标题")
                // 设置接口描述信息
                .description("这是swagger2接口文档")
                // 设置作者信息
                .contact(new Contact("大锤", "http://www.baidu.com", "22227894845@qq.com"))
                // 设置版本号
                .version("1.0")
                .build();
    }
}












